import axios from "axios";

const upload = async (blob: Blob) => {
  const formData = new FormData();
  formData.append("file", blob, "test.png");
  try {
    const res = await axios.post("/api/utils/upload", formData, {
      headers: {
        "Content-Type": "multipart/form-data",
      },
    });
    console.log("API Response:", res.data); // 检查响应数据
    return res.data.data.url;
  } catch (error) {
    console.error("Upload failed:", error);
    throw error;
  }
};

export const uploadImage = async (blob: Blob) => {
  // const url = await upload(blob);
  // console.log("url",url);
  // return url;
};
